package services

import (
	"context"
	"my-gin-tiktok/app/models"
	"my-gin-tiktok/global"
)

type messageService struct{}

var MessageService = new(messageService)

// CreateMessage 建立消息
func (s *messageService) CreateMessage(ctx context.Context, fromID int64, toID int64, contents string) error {
	message := models.Message{FromUserID: fromID, ToUserID: toID, Contents: contents}
	return global.App.DB.WithContext(ctx).Create(&message).Error
}

// DeleteMessage 删除消息
func (s *messageService) DeleteMessage(ctx context.Context, messageID int64) error {
	return global.App.DB.WithContext(ctx).Delete(&models.Message{}, messageID).Error
}
